package com.demo.chapter3lambda;

import java.util.function.Predicate;

import com.demo.domain.Apple;

/**谓词复合
 * @author dell
 *
 */
public class PredicateComposite {

	public void demo(){
		Predicate<Apple> red = a -> a.getColor().equals("red");
		//取非
		Predicate<Apple> notRed = red.negate();
		//红色的并且重150
		Predicate<Apple> redAndHeavy = red.and(a -> a.getWeight() > 150);
		//红色的并且重150或者是绿色的
		Predicate<Apple> redAndHeavyOrGreen = red.and(a -> a.getWeight() > 150).or(a -> a.getColor().equals("green"));
	}

}
